import re
#/w匹配字母及下划线
print(re.findall('\w','aAbc123_*()-='))
#/W非字母及下划线
print(re.findall('\W','aAbc123_*()-= '))
#\s匹配任意空白字符，等价于[\t\n\r\f](空白字符)
print(re.findall('\s','aAbc123_*()-= \r\n\t\f '))
#\S非空字符
print(re.findall('\S','aAbc123_*()-= \r\n\t\f '))
#\d匹配数字
print(re.findall('\d','aAbc123_*()-= \r\n\t\f '))
#\D非数字
print(re.findall('\D','aAbc123_*()-= \r\n\t\f '))
#\A,从头开始匹配（匹配字符串开始）,只匹配一个
print(re.findall('\Aalex','alexc1 alex23_*()-= \r\n\t\f '))
print(re.findall('alex','alexc1 alex23_*()-= \r\n\t\f '))#['alex', 'alex']
#\Z以什么结尾，只匹配结尾,这能匹配换行前的结果
print(re.findall('sb\Z','alexc1 alex23_*()-= \r\n\t\f sb'))
print(re.findall('sb\$','''alexc1 alex23_*()-= \
r\n\t\f 
sc
sb
'''))
print('*' * 50)
#^ 匹配字符串开头
print(re.findall('^abc','abcsdadsadabc sb'))
#$以什么结尾
print(re.findall('sb$','alexc1 alex23_*()-= \r\n\t\f sb'))
print(re.findall('^sb$','salexc1 alex23_*()-= \r\n\t\f sb'))
print(re.findall('^abcd$','abcd'))


from bs4 import BeautifulSoup
import re
import urllib.request, urllib.error
import xlwt
import sqlite3


def main():
    baseurl = "https://movie.douban.com/top250?start="

    datalist = getData(baseurl)
    savepath = ".\\豆瓣电影top250.xls"
    # saveData(savepath)

    print(askURL("https://movie.douban.com/top250?start=0"))


def getData(baseurl):
    datalist = []
    for i in range(0, 10):
        url = baseurl + str(i * 25)
        askURL(url)
        html = askURL(url)

    return datalist


def askURL(url):
    headers = {
        "User-Agent": "Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1",
        "Accept-Encoding": "gzip, deflate, br"}

    request = urllib.request.Request(url, headers=headers)

    html = " "

    try:

        response = urllib.request.urlopen(request)
        html = response.read()
    except urllib.error.URLError as e:

        if hasattr(e, "code"):
            print(e.code)
        if hasattr(e, "reason"):
            print(e.reason)
    return html


def saveData(savepath):
    print("save...")


if __name__ == '__main__':
    # 调用函数
    #main()
    pass

n=input('请输入邮箱')
pattern=re.compile('\w+@\w{1,2}\.\w+$')
print(re.findall(pattern,n))




